package com.wb.designmode.observable;

import org.junit.Test;

public class StartMain {

    @Test
    public void runObServer() {
        ObServable xiaoMing = new User("小明");
        Friend xiaoHong = new Friend("小红");
        Friend xiaoDong = new Friend("小东");
        xiaoMing.addObserver(xiaoHong);
        xiaoMing.addObserver(xiaoDong);
        xiaoMing.notifyObservers("今天真开心");
        // 小红和小明闹别扭了，小红取消订阅小明的朋友圈
        xiaoMing.removeObserver(xiaoHong);
        xiaoMing.notifyObservers("希望明天也像今天一样开心");

    }
}
